import { defineConfig,loadEnv } from "vite";
import vue from "@vitejs/plugin-vue";
import path from "path";
import Components from 'unplugin-vue-components/vite'
import { ElementPlusResolver } from 'unplugin-vue-components/resolvers'

// https://vitejs.dev/config/
export default ({mode})=> defineConfig({
  base: loadEnv(mode,process.cwd()).VITE_APP_BASE_URL,// 若服务器不是将该项目放在根目录的则 需要此设置 和服务器上同名
  css: {
    preprocessorOptions: {
      scss: {
        additionalData:'@import "./src/style/index.scss";'
      }
    }
  },
  plugins: [
    vue(),
    Components({
      resolvers: [ElementPlusResolver()],
    }),
  ],
  resolve: {
    alias: {
      "@": path.resolve(__dirname, "./src"),
    },
  },
  server: {
    proxy: {
      "/devapi": {
        target: "http://8.136.199.33:8602/adminapi",
        changeOrigin: true, //允许跨域
        rewrite: (path) => path.replace(/\/devapi/, "/"),
      },
    },
  },
  build: {
    sourcemap: false,
    chunkSizeWarningLimit: 5000,
    outDir:"admin"
  },
});
